package com.example.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author 段誉
 * @create 2019-02-20 10:06
 */
public class MysqlCondition implements Condition {
  /**
   *
   * @param context
   * @param metadata
   * @return
   */
  @Override
  public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    //获取配置文件的值
    return "mysql".equals(context.getEnvironment().getProperty("db-type"));
  }
}
